/*     */ package com.qmsk.business.task.overServiceRecord.controller;
/*     */ 
/*     */ import com.qmsk.business.info.taskRemind.dao.TaskRemindDao;
/*     */ import com.qmsk.business.manage.user.dao.UserDAO;
/*     */ import com.qmsk.business.member.member.dao.MemberDAO;
/*     */ import com.qmsk.business.task.overServiceRecord.dao.OverServiceRecordDao;
/*     */ import com.qmsk.business.weixin.customMenu.weiXinUtil.WeiXinUtil;
/*     */ import com.utils.basic.CDateTimeComm;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"overServiceRecord"})
/*     */ public class OverServiceRecordController
/*     */ {
/*  35 */   private static final Logger logger = Logger.getLogger(OverServiceRecordController.class);
/*     */ 
/*     */   @Autowired
/*     */   private OverServiceRecordDao dao;
/*     */ 
/*     */   @Autowired
/*     */   private UserDAO userDao;
/*     */ 
/*     */   @Autowired
/*     */   private MemberDAO memberDAO;
/*     */ 
/*     */   @Autowired
/*     */   private TaskRemindDao taskRemindDao;
/*     */ 
/*     */   @RequestMapping(value={"find/overServiceList/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListShopIdOpt(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize) { nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  52 */       Map params = new HashMap();
/*  53 */       MapUtils.addToMap(params, "id", RequestUtils.getStringOfId(request));
/*  54 */       String shopId = RequestUtils.getString(request, "shopId");
/*  55 */       MapUtils.addToMap(params, "shopId", shopId);
/*     */ 
/*  57 */       MapUtils.addToMap(params, "openId", 
/*  58 */         RequestUtils.getString(request, "openId"));
/*  59 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  60 */         nPageSize);
/*  61 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  63 */       logger.error(e);
/*  64 */       ResponseUtils.setErrorMsgResponse(
/*  65 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/overServiceOfUserId/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void overServiceOfUserId(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  72 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  74 */       Map params = new HashMap();
/*  75 */       MapUtils.addToMap(params, "id", RequestUtils.getStringOfId(request));
/*  76 */       String shopId = RequestUtils.getString(request, "shopId");
/*  77 */       String userId = RequestUtils.getString(request, "userId");
/*  78 */       MapUtils.addToMap(params, "shopId", shopId);
/*  79 */       MapUtils.addToMap(params, "userId", userId);
/*  80 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, 
/*  81 */         nPageSize);
/*  82 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  84 */       logger.error(e);
/*  85 */       ResponseUtils.setErrorMsgResponse(
/*  86 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"insert/insertInfo"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  96 */       int nResult = 0;
/*  97 */       String sData = RequestUtils.getStringOfData(request);
/*  98 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*  99 */       if ((p != null) && (p.isExistsInsertRows())) {
/* 100 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListInsertRows().get(0);
/* 101 */         g.autoAddHeadData("SubMitdate", new Date());
/* 102 */         g.autoAddHeadData("Status", Integer.valueOf(0));
/* 103 */         String TimeName = ObjectComm.objectToString(g.getValueOfName("TimeName"));
/* 104 */         String CarTypeName = ObjectComm.objectToString(g.getValueOfName("CarTypeName"));
/* 105 */         String OrderDate = ObjectComm.objectToString(g.getValueOfName("OrderDate"));
/* 106 */         String License = ObjectComm.objectToString(g.getValueOfName("License"));
/* 107 */         String xm = ObjectComm.objectToString(g.getValueOfName("xm"));
/* 108 */         String OrderDate2 = OrderDate + TimeName;
/* 109 */         nResult = this.dao.applyUpdates(p);
/* 110 */         if (nResult > 0) {
/* 111 */           Long userId = ObjectComm.objectToLong(g.getValueOfName("userId"));
/* 112 */           Long memberId = ObjectComm.objectToLong(g.getValueOfName("memberId"));
/* 113 */           Long shopId = ObjectComm.objectToLong(g.getValueOfName("shopId"));
/* 114 */           Long CustomerID = ObjectComm.objectToLong(g.getValueOfName("CustomerID"));
/* 115 */           String customerName = ObjectComm.objectToString(g.getValueOfName("CustomerName"));
/* 116 */           String mp = ObjectComm.objectToString(g.getValueOfName("LinkPhone"));
/* 117 */           String custOpenId = this.memberDAO.getOpenId(CustomerID);
/* 118 */           Long id = this.dao.getLastId();
/*     */ 
/* 120 */           GsonHeadOneRow user = this.userDao.selectUserById(userId);
/* 121 */           String content = "服务预约通知:\n客户姓名：" + customerName + "\n联系电话：" + mp + "\n预约项目：" + xm + "\n预约时间：" + OrderDate2 + "\n车牌号：" + License + "\n车型：" + CarTypeName;
/* 122 */           if (user != null) {
/* 123 */             String openId = (String)user.getValueOfName("openId");
/* 124 */             String name = (String)user.getValueOfName("name");
/* 125 */             String userMp = (String)user.getValueOfName("mp");
/* 126 */             WeiXinUtil.sendTextMessageOfMain("服务预约受理通知:\n尊敬的" + customerName + ",我们已经收到您的服务预约,我是您的服务顾问：" + name + ",\n联系电话：" + userMp, custOpenId);
/* 127 */             if (StringUtils.isNotEmpty(openId)) {
/* 128 */               logger.error(openId);
/* 129 */               WeiXinUtil.sendTextMessageOfMain(content, openId);
/*     */             }
/* 131 */             String[] head = { "CreateTime", "AssignTime", "TaskMemo", "Status", "License", "CustName", "Mp", "CustID", "MemberID", "ShopId", "AssignId", "AssignName", "RemindID", "taskDetilId" };
/* 132 */             Object[] data = { new Date(), OrderDate, content, Integer.valueOf(1), License, customerName, mp, CustomerID, memberId, shopId, userId, name, Integer.valueOf(8), id };
/* 133 */             nResult = this.taskRemindDao.insertGsonHeadOneRow(new GsonHeadOneRow(head, data));
/*     */           }
/*     */           else {
/* 136 */             String[] head = { "CreateTime", "AssignTime", "TaskMemo", "Status", "License", "CustName", "Mp", "CustID", "MemberID", "ShopId", "RemindID", "taskDetilId" };
/* 137 */             Object[] data = { new Date(), OrderDate, content, Integer.valueOf(0), License, customerName, mp, CustomerID, memberId, shopId, Integer.valueOf(8), id };
/* 138 */             nResult = this.taskRemindDao.insertGsonHeadOneRow(new GsonHeadOneRow(head, data));
/*     */           }
/* 140 */           if (nResult > 0)
/*     */           {
/* 142 */             DbConnection.commit();
/*     */           }
/*     */           else DbConnection.rollback();
/*     */         }
/*     */         else
/*     */         {
/* 148 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 151 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 152 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 153 */         response);
/*     */     } catch (Exception e) {
/* 155 */       logger.error(e);
/* 156 */       DbConnection.rollback();
/* 157 */       ResponseUtils.setErrorMsgResponse(
/* 158 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 159 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void edit(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 169 */       int nResult = 0;
/* 170 */       String sData = RequestUtils.getStringOfData(request);
/* 171 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 172 */       if (p != null) {
/* 173 */         nResult = this.dao.applyUpdates(p);
/* 174 */         if (nResult > 0)
/* 175 */           DbConnection.commit();
/*     */         else {
/* 177 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 180 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 181 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 182 */         response);
/*     */     } catch (Exception e) {
/* 184 */       logger.error(e);
/* 185 */       DbConnection.rollback();
/* 186 */       ResponseUtils.setErrorMsgResponse(
/* 187 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 188 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit/shopId/{shopId}/orderDate/{id}/{timeId}/{newSs}/{oldSs}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void editSchdule(HttpServletRequest request, HttpServletResponse response, @PathVariable("newSs") Integer status, @PathVariable("oldSs") Integer oldSs, @PathVariable("id") Long id, @PathVariable("timeId") Integer timeId)
/*     */   {
/*     */     try
/*     */     {
/* 198 */       int nResult = this.dao.updateStatus(id, status);
/* 199 */       if (nResult > 0)
/*     */       {
/* 201 */         if (status.intValue() == 1) {
/* 202 */           String arrvDate = CDateTimeComm.dateToyyyymmdd(new Date());
/* 203 */           this.dao.updateArrvDate(id, arrvDate);
/* 204 */           DbConnection.commit();
/* 205 */           String[] heads = { "arrvDate" };
/* 206 */           Object[] datas = { arrvDate };
/* 207 */           ResponseUtils.toGsonEbRst(heads, datas, response);
/* 208 */           return; }
/* 209 */         DbConnection.commit();
/* 210 */         ResponseUtils.setSqlResultResponse(nResult, 
/* 211 */           RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 212 */           response);
/*     */ 
/* 214 */         return; }
/* 215 */       DbConnection.rollback();
/* 216 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 217 */         RequestUtils.getSqlUpdateDataErrorMessage(request), 
/* 218 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 221 */       logger.error(e);
/* 222 */       DbConnection.rollback();
/* 223 */       ResponseUtils.setErrorMsgResponse(
/* 224 */         RequestUtils.getSqlUpdateDataErrorMessage(request) + ":" + 
/* 225 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 233 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 235 */       String[] strParams = id.split(",");
/* 236 */       int nResult = this.dao.deleteParams(strParams);
/* 237 */       if (nResult > 0)
/* 238 */         DbConnection.commit();
/*     */       else {
/* 240 */         DbConnection.rollback();
/*     */       }
/* 242 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 243 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 244 */         response);
/*     */     } catch (Exception e) {
/* 246 */       DbConnection.rollback();
/* 247 */       logger.error(e);
/* 248 */       ResponseUtils.setErrorMsgResponse(
/* 249 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 250 */         e.getMessage(), response); } }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit/deal"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void deal(HttpServletRequest request, HttpServletResponse response) {
/*     */     try {
/* 256 */       int nResult = 0;
/* 257 */       Long id = null;
/* 258 */       String sData = RequestUtils.getStringOfData(request);
/* 259 */       String reply = RequestUtils.getString(request, "reply");
/* 260 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 261 */       if ((p != null) && (p.isExistsUpdateRows())) {
/* 262 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListUpdateRows().get(0);
/* 263 */         g.autoInsertHeadData("CancelDate", new Date());
/* 264 */         g.autoInsertHeadData("replyDate", new Date());
/* 265 */         id = ObjectComm.objectToLong(g.getValueOfName("id"));
/* 266 */         String openId = this.dao.getOpenIdById(id);
/*     */ 
/* 268 */         nResult = this.dao.applyUpdates(p);
/* 269 */         if (nResult > 0) {
/* 270 */           DbConnection.commit();
/* 271 */           WeiXinUtil.sendTextMessageOfMain("服务预约处理情况:\n" + reply, openId);
/*     */         } else {
/* 273 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 276 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 277 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 278 */         response);
/*     */     } catch (Exception e) {
/* 280 */       logger.error(e);
/* 281 */       DbConnection.rollback();
/* 282 */       ResponseUtils.setErrorMsgResponse(
/* 283 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 284 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.task.overServiceRecord.controller.OverServiceRecordController
 * JD-Core Version:    0.5.3
 */